<?php

namespace app\controllers;

use app\components\Controller;
use app\logic\MenuLogic;
use yii\web\HttpException;


/**
 * 菜单
 */
class MenuController extends Controller
{
    protected function verbs()
    {
        return [
            'index' => ['GET'],
            'create' => ['POST'],
            'update' => ['POST'],
            'delete' => ['GET'],
            'status' => ['GET'],
            'view' => ['GET'],
            'get-param' => ['GET'],
            'get-suggest' => ['GET'],
        ];
    }

    /**
     * 列表
     * @return mixed
     * @throws HttpException
     */
    public function actionIndex()
    {
        return MenuLogic::getList(getParams());
    }

    /**
     * 创建
     * @throws HttpException
     */
    public function actionCreate()
    {
        return MenuLogic::create(getParams());
    }

    /**
     * 编辑
     * @throws HttpException
     */
    public function actionUpdate()
    {
        return MenuLogic::update(getParams());
    }

    /**
     * 状态
     * @throws HttpException
     */
    public function actionStatus()
    {
        return MenuLogic::status(getParams());
    }

    /**
     * 详情
     * @throws HttpException
     */
    public function actionView()
    {
        return MenuLogic::view(getParams());
    }


    /**
     * 删除
     * @throws HttpException
     * @throws \Throwable
     */
    public function actionDelete()
    {
        return MenuLogic::delete(getParams());
    }

    /**
     * 表单信息
     * @return array
     * @throws HttpException
     */
    public function actionGetParam()
    {
        return MenuLogic::getParam(getParams());
    }

    /**
     * 获取权限列表
     * @return array
     * @throws HttpException
     */
    public function actionGetItem()
    {
        return MenuLogic::getItem();
    }
}